<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
	<meta name="keywords" content="open-API" />
	<meta name="description" content="open-API" />
	<!-- 网页标签标题 -->
	<title>open-API</title>
	<link rel="shortcut icon" href="/img/nacos.ico"/>
	<link rel="stylesheet" href="/build/documentation.css" />
</head>
<body>
	<div id="root"><div class="documentation-page" data-reactroot="" data-reactid="1" data-react-checksum="-24550397"><header class="header-container header-container-normal" data-reactid="2"><div class="header-body" data-reactid="3"><a href="/zh-cn/index.html" data-reactid="4"><img class="logo" src="/img/nacos_colorful.png" data-reactid="5"/></a><span class="language-switch language-switch-normal" data-reactid="6">En</span><div class="header-menu" data-reactid="7"><img class="header-menu-toggle" src="/img/menu_gray.png" data-reactid="8"/><ul data-reactid="9"><li class="menu-item menu-item-normal" data-reactid="10"><a href="/zh-cn/index.html" data-reactid="11">首页</a></li><li class="menu-item menu-item-normal menu-item-normal-active" data-reactid="12"><a href="/zh-cn/docs/what-is-nacos.html" data-reactid="13">文档</a></li><li class="menu-item menu-item-normal" data-reactid="14"><a href="/zh-cn/blog/index.html" data-reactid="15">博客</a></li><li class="menu-item menu-item-normal" data-reactid="16"><a href="/zh-cn/community/index.html" data-reactid="17">社区</a></li><li class="menu-item menu-item-normal" data-reactid="18"><a href="http://console.nacos.io/nacos/index.html" data-reactid="19">控制台样例</a></li></ul></div></div></header><div class="bar" data-reactid="20"><div class="bar-body" data-reactid="21"><img src="/img/docs.png" class="front-img" data-reactid="22"/><div class="bar-title" data-reactid="23"><span data-reactid="24">Nacos 文档</span><div class="bone bone-light" data-reactid="25"></div></div><img src="/img/docs.png" class="back-img" data-reactid="26"/></div></div><section class="content-section" data-reactid="27"><div class="content-body" data-reactid="28"><div class="sidemenu" data-reactid="29"><div class="sidemenu-toggle" data-reactid="30"><img src="https://img.alicdn.com/tfs/TB1E6apXHGYBuNjy0FoXXciBFXa-200-200.png" data-reactid="31"/></div><ul data-reactid="32"><li class="menu-item menu-item-level-1" data-reactid="33"><span data-reactid="34">Nacos </span><ul data-reactid="35"><li style="height:144px;overflow:hidden;" class="menu-item menu-item-level-2" data-reactid="36"><span data-reactid="37"><!-- react-text: 38 -->Nacos是什么?<!-- /react-text --><img style="transform:rotate(0deg);" class="menu-toggle" src="/img/arrow_down.png" data-reactid="39"/></span><ul data-reactid="40"><li class="menu-item menu-item-level-3" data-reactid="41"><a href="/zh-cn/docs/what-is-nacos.html" target="_self" data-reactid="42">Nacos简介</a></li><li class="menu-item menu-item-level-3" data-reactid="43"><a href="/zh-cn/docs/concepts.html" target="_self" data-reactid="44">概念</a></li><li class="menu-item menu-item-level-3" data-reactid="45"><a href="/zh-cn/docs/architecture.html" target="_self" data-reactid="46">架构</a></li></ul></li><li style="height:216px;overflow:hidden;" class="menu-item menu-item-level-2" data-reactid="47"><span data-reactid="48"><!-- react-text: 49 -->快速开始<!-- /react-text --><img style="transform:rotate(0deg);" class="menu-toggle" src="/img/arrow_down.png" data-reactid="50"/></span><ul data-reactid="51"><li class="menu-item menu-item-level-3" data-reactid="52"><a href="/zh-cn/docs/quick-start.html" target="_self" data-reactid="53">快速开始</a></li><li class="menu-item menu-item-level-3" data-reactid="54"><a href="/zh-cn/docs/quick-start-spring.html" target="_self" data-reactid="55">Nacos Spring</a></li><li class="menu-item menu-item-level-3" data-reactid="56"><a href="/zh-cn/docs/quick-start-spring-boot.html" target="_self" data-reactid="57">Nacos Spring Boot</a></li><li class="menu-item menu-item-level-3" data-reactid="58"><a href="/zh-cn/docs/quick-start-spring-cloud.html" target="_self" data-reactid="59">Nacos Spring Cloud</a></li><li class="menu-item menu-item-level-3" data-reactid="60"><a href="/zh-cn/docs/quick-start-docker.html" target="_self" data-reactid="61">Nacos Docker</a></li></ul></li><li style="height:180px;overflow:hidden;" class="menu-item menu-item-level-2" data-reactid="62"><span data-reactid="63"><!-- react-text: 64 -->用户指南<!-- /react-text --><img style="transform:rotate(0deg);" class="menu-toggle" src="/img/arrow_down.png" data-reactid="65"/></span><ul data-reactid="66"><li class="menu-item menu-item-level-3" data-reactid="67"><a href="/zh-cn/docs/sdk.html" target="_self" data-reactid="68">Java的SDK</a></li><li class="menu-item menu-item-level-3" data-reactid="69"><a href="/zh-cn/docs/other-language.html" target="_self" data-reactid="70">其他语言的SDK</a></li><li class="menu-item menu-item-level-3" data-reactid="71"><a href="/zh-cn/docs/open-API.html" target="_self" data-reactid="72">Open-API指南</a></li><li class="menu-item menu-item-level-3" data-reactid="73"><a href="/zh-cn/docs/nacos-spring.html" target="_self" data-reactid="74">Nacos Spring</a></li></ul></li><li style="height:36px;overflow:hidden;" class="menu-item menu-item-level-2" data-reactid="75"><span data-reactid="76"><!-- react-text: 77 -->运维指南<!-- /react-text --><img style="transform:rotate(-90deg);" class="menu-toggle" src="/img/arrow_down.png" data-reactid="78"/></span><ul data-reactid="79"><li class="menu-item menu-item-level-3" data-reactid="80"><a href="/zh-cn/docs/deployment.html" target="_self" data-reactid="81">部署手册</a></li><li class="menu-item menu-item-level-3" data-reactid="82"><a href="/zh-cn/docs/cluster-mode-quick-start.html" target="_self" data-reactid="83">集群部署说明</a></li><li class="menu-item menu-item-level-3" data-reactid="84"><a href="/zh-cn/docs/managementAPI.html" target="_self" data-reactid="85">运维API</a></li><li class="menu-item menu-item-level-3" data-reactid="86"><a href="/zh-cn/docs/CLI-guide.html" target="_self" data-reactid="87">命令行手册</a></li><li class="menu-item menu-item-level-3" data-reactid="88"><a href="/zh-cn/docs/console-guide.html" target="_self" data-reactid="89">控制台手册</a></li></ul></li><li style="height:36px;overflow:hidden;" class="menu-item menu-item-level-2" data-reactid="90"><span data-reactid="91"><!-- react-text: 92 -->开源共建<!-- /react-text --><img style="transform:rotate(-90deg);" class="menu-toggle" src="/img/arrow_down.png" data-reactid="93"/></span><ul data-reactid="94"><li class="menu-item menu-item-level-3" data-reactid="95"><a href="/zh-cn/docs/contributing.html" target="_self" data-reactid="96">贡献源码</a></li><li class="menu-item menu-item-level-3" data-reactid="97"><a href="/zh-cn/docs/activity.html" target="_self" data-reactid="98">Nacos有奖活动介绍</a></li><li class="menu-item menu-item-level-3" data-reactid="99"><a href="/zh-cn/docs/pull-request.html" target="_self" data-reactid="100">pull request模板</a></li><li class="menu-item menu-item-level-3" data-reactid="101"><a href="/zh-cn/docs/how-to-reporting-bugs.html" target="_self" data-reactid="102">如何提交问题报告</a></li><li class="menu-item menu-item-level-3" data-reactid="103"><a href="/zh-cn/docs/roadmap.html" target="_self" data-reactid="104">Nacos规划</a></li><li class="menu-item menu-item-level-3" data-reactid="105"><a href="/zh-cn/docs/use-nacos-with-springcloud.html" target="_self" data-reactid="106">Nacos支持SpringCloud生态</a></li><li class="menu-item menu-item-level-3" data-reactid="107"><a href="/zh-cn/docs/use-nacos-with-dubbo.html" target="_self" data-reactid="108">nacos支持dubbo生态</a></li><li class="menu-item menu-item-level-3" data-reactid="109"><a href="/zh-cn/docs/use-nacos-with-kubernetes.html" target="_self" data-reactid="110">Nacos支持k8s</a></li><li class="menu-item menu-item-level-3" data-reactid="111"><a href="/zh-cn/docs/use-nacos-with-istio.html" target="_self" data-reactid="112">nacos支持istio</a></li></ul></li><li style="height:36px;overflow:hidden;" class="menu-item menu-item-level-2" data-reactid="113"><span data-reactid="114"><!-- react-text: 115 -->社区<!-- /react-text --><img style="transform:rotate(-90deg);" class="menu-toggle" src="/img/arrow_down.png" data-reactid="116"/></span><ul data-reactid="117"><li class="menu-item menu-item-level-3" data-reactid="118"><a href="/zh-cn/docs/community.html" target="_self" data-reactid="119">社区</a></li></ul></li></ul></li></ul></div><div class="doc-content markdown-body" data-reactid="120"><h1>配置管理</h1>
<h2>获取配置</h2>
<h3>描述</h3>
<p>获取Nacos上的配置。</p>
<h3>请求类型</h3>
<p>GET</p>
<h3>请求URL</h3>
<p>/nacos/v1/cs/configs</p>
<h3>请求参数</h3>
<table>
<thead>
<tr>
<th style="text-align:left">名称</th>
<th style="text-align:left">类型</th>
<th style="text-align:left">是否必须</th>
<th style="text-align:left">描述</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">tenant</td>
<td style="text-align:left">string</td>
<td style="text-align:left">否</td>
<td style="text-align:left">租户信息，对应 Nacos 的命名空间字段。</td>
</tr>
<tr>
<td style="text-align:left">dataId</td>
<td style="text-align:left">string</td>
<td style="text-align:left">是</td>
<td style="text-align:left">配置 ID。</td>
</tr>
<tr>
<td style="text-align:left">group</td>
<td style="text-align:left">string</td>
<td style="text-align:left">是</td>
<td style="text-align:left">配置分组。</td>
</tr>
</tbody>
</table>
<h3>返回参数</h3>
<table>
<thead>
<tr>
<th style="text-align:left">参数类型</th>
<th style="text-align:left">描述</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">string</td>
<td style="text-align:left">配置值</td>
</tr>
</tbody>
</table>
<h3>错误编码</h3>
<table>
<thead>
<tr>
<th style="text-align:left">错误代码</th>
<th style="text-align:left">描述</th>
<th style="text-align:left">语义</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">400</td>
<td style="text-align:left">Bad Request</td>
<td style="text-align:left">客户端请求中的语法错误</td>
</tr>
<tr>
<td style="text-align:left">403</td>
<td style="text-align:left">Forbidden</td>
<td style="text-align:left">没有权限</td>
</tr>
<tr>
<td style="text-align:left">404</td>
<td style="text-align:left">Not Found</td>
<td style="text-align:left">无法找到资源</td>
</tr>
<tr>
<td style="text-align:left">500</td>
<td style="text-align:left">Internal Server Error</td>
<td style="text-align:left">服务器内部错误</td>
</tr>
<tr>
<td style="text-align:left">200</td>
<td style="text-align:left">OK</td>
<td style="text-align:left">正常</td>
</tr>
</tbody>
</table>
<h3>示例</h3>
<ul>
<li>
<p>请求示例</p>
<pre><code class="language-plain">http:serverIp:8848/nacos/v1/cs/configs?dataId=dataIdparam&amp;group=groupParam&amp;tenant=tenantParam

</code></pre>
</li>
<li>
<p>返回示例</p>
<pre><code>contentTest
</code></pre>
</li>
</ul>
<h2>监听配置</h2>
<h3>描述</h3>
<p>监听 Nacos 上的配置，以便实时感知配置变更。如果配置变更，则用<a href="~~64131~~">获取配置</a>接口获取配置的最新值，动态刷新本地缓存。</p>
<p>注册监听采用的是异步 Servlet 技术。注册监听本质就是带着配置和配置值的 MD5 值和后台对比。如果 MD5 值不一致，就立即返回不一致的配置。如果值一致，就等待住 30 秒。返回值为空。</p>
<h3>请求类型</h3>
<p>POST</p>
<h3>请求URL</h3>
<p>/nacos/v1/cs/configs/listener</p>
<h3>请求参数</h3>
<div class="bi-table">
  <table>
    <colgroup>
      <col width="auto" />
      <col width="118px" />
      <col width="115px" />
      <col width="325px" />
    </colgroup>
    <tbody>
      <tr>
        <td rowspan="1" colSpan="1">
          <div data-type="p">名称</div>
        </td>
        <td rowspan="1" colSpan="1">
          <div data-type="p">类型</div>
        </td>
        <td rowspan="1" colSpan="1">
          <div data-type="p">是否必须</div>
        </td>
        <td rowspan="1" colSpan="1">
          <div data-type="p">描述</div>
        </td>
      </tr>
      <tr>
        <td rowspan="1" colSpan="1">
          <div data-type="p">Listening-Configs</div>
        </td>
        <td rowspan="1" colSpan="1">
          <div data-type="p">string</div>
        </td>
        <td rowspan="1" colSpan="1">
          <div data-type="p">是</div>
        </td>
        <td rowspan="1" colSpan="1">
          <div data-type="p">监听数据报文。格式为 dataId^2Group^2contentMD5^2tenant^1或者dataId^2Group^2contentMD5^1。</div>
          <ul data-type="unordered-list">
            <li data-type="list-item" data-list-type="unordered-list">
              <div data-type="p">dataId：配置 ID</div>
            </li>
            <li data-type="list-item" data-list-type="unordered-list">
              <div data-type="p">group：配置分组</div>
            </li>
            <li data-type="list-item" data-list-type="unordered-list">
              <div data-type="p">contentMD5：配置内容 MD5 值</div>
            </li>
            <li data-type="list-item" data-list-type="unordered-list">
              <div data-type="p">tenant：租户信息，对应 Nacos 的命名空间字段(非必填)</div>
            </li>
          </ul>
        </td>
      </tr>
    </tbody>
  </table>
</div>
<h3>Header 参数</h3>
<table>
<thead>
<tr>
<th style="text-align:left">名称</th>
<th style="text-align:left">类型</th>
<th style="text-align:left">是否必须</th>
<th style="text-align:left">描述</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">Long-Pulling-Timeout</td>
<td style="text-align:left">string</td>
<td style="text-align:left">是</td>
<td style="text-align:left">长轮训等待 30s，此处填写 30000。</td>
</tr>
</tbody>
</table>
<h3>参数说明</h3>
<ul>
<li>配置多个字段间分隔符：^2  = Character.toString((char) 2</li>
<li>配置间分隔符：^1 = Character.toString((char) 1)</li>
<li>contentMD5:  MD5(content)，第一次本地缓存为空，所以这块为空串</li>
</ul>
<h3>返回参数</h3>
<table>
<thead>
<tr>
<th style="text-align:left">参数类型</th>
<th style="text-align:left">描述</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">string</td>
<td style="text-align:left">配置值</td>
</tr>
</tbody>
</table>
<h3>错误编码</h3>
<table>
<thead>
<tr>
<th style="text-align:left">错误代码</th>
<th style="text-align:left">描述</th>
<th style="text-align:left">语义</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">400</td>
<td style="text-align:left">Bad Request</td>
<td style="text-align:left">客户端请求中的语法错误</td>
</tr>
<tr>
<td style="text-align:left">403</td>
<td style="text-align:left">Forbidden</td>
<td style="text-align:left">没有权限</td>
</tr>
<tr>
<td style="text-align:left">404</td>
<td style="text-align:left">Not Found</td>
<td style="text-align:left">无法找到资源</td>
</tr>
<tr>
<td style="text-align:left">500</td>
<td style="text-align:left">Internal Server Error</td>
<td style="text-align:left">服务器内部错误</td>
</tr>
<tr>
<td style="text-align:left">200</td>
<td style="text-align:left">OK</td>
<td style="text-align:left">正常</td>
</tr>
</tbody>
</table>
<h3>示例</h3>
<ul>
<li>请求示例</li>
</ul>
<pre><code>http://serverIp:8848/nacos/v1/cs/configs/listener

POST 请求体数据内容：

Listening-Configs=dataId^2group^2contentMD5^2tenant^1
</code></pre>
<ul>
<li>返回示例</li>
</ul>
<pre><code>如果配置变化

dataId^2group^2tenant^1

如果配置无变化：会返回空串
</code></pre>
<h2>发布配置</h2>
<h3>描述</h3>
<p>发布 Nacos 上的配置。</p>
<h3>请求类型</h3>
<p>POST</p>
<h3>请求 URL</h3>
<p>/nacos/v1/cs/configs</p>
<h3>请求参数</h3>
<table>
<thead>
<tr>
<th style="text-align:left">名称</th>
<th style="text-align:left">类型</th>
<th style="text-align:left">是否必须</th>
<th style="text-align:left">描述</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">tenant</td>
<td style="text-align:left">string</td>
<td style="text-align:left">否</td>
<td style="text-align:left">租户信息，对应 Nacos 的命名空间字段</td>
</tr>
<tr>
<td style="text-align:left">dataId</td>
<td style="text-align:left">string</td>
<td style="text-align:left">是</td>
<td style="text-align:left">配置 ID</td>
</tr>
<tr>
<td style="text-align:left">group</td>
<td style="text-align:left">string</td>
<td style="text-align:left">是</td>
<td style="text-align:left">配置分组</td>
</tr>
<tr>
<td style="text-align:left">content</td>
<td style="text-align:left">string</td>
<td style="text-align:left">是</td>
<td style="text-align:left">配置内容</td>
</tr>
</tbody>
</table>
<h3>返回参数</h3>
<table>
<thead>
<tr>
<th style="text-align:left">参数类型</th>
<th style="text-align:left">描述</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">boolean</td>
<td style="text-align:left">是否发布成功</td>
</tr>
</tbody>
</table>
<h3>错误编码</h3>
<table>
<thead>
<tr>
<th style="text-align:left">错误代码</th>
<th style="text-align:left">描述</th>
<th style="text-align:left">语义</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">400</td>
<td style="text-align:left">Bad Request</td>
<td style="text-align:left">客户端请求中的语法错误</td>
</tr>
<tr>
<td style="text-align:left">403</td>
<td style="text-align:left">Forbidden</td>
<td style="text-align:left">没有权限</td>
</tr>
<tr>
<td style="text-align:left">404</td>
<td style="text-align:left">Not Found</td>
<td style="text-align:left">无法找到资源</td>
</tr>
<tr>
<td style="text-align:left">500</td>
<td style="text-align:left">Internal Server Error</td>
<td style="text-align:left">服务器内部错误</td>
</tr>
<tr>
<td style="text-align:left">200</td>
<td style="text-align:left">OK</td>
<td style="text-align:left">正常</td>
</tr>
</tbody>
</table>
<h3>示例</h3>
<ul>
<li>请求示例</li>
</ul>
<pre><code>http:serverIp:8848/nacos/v1/cs/configs

http body：
dataId=dataIdparam&amp;group=groupParam&amp;tenant=tenantParam&amp;content=contentParam

</code></pre>
<ul>
<li>返回示例</li>
</ul>
<pre><code>true
</code></pre>
<h2>删除配置</h2>
<h3>描述</h3>
<p>删除 Nacos 上的配置。</p>
<h3>请求类型</h3>
<p>DELETE</p>
<h3>请求 URL</h3>
<p>/nacos/v1/cs/configs</p>
<h3>请求参数</h3>
<table>
<thead>
<tr>
<th style="text-align:left">名称</th>
<th style="text-align:left">类型</th>
<th style="text-align:left">是否必须</th>
<th style="text-align:left">描述</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">tenant</td>
<td style="text-align:left">string</td>
<td style="text-align:left">否</td>
<td style="text-align:left">租户信息，对应 Naocs 的命名空间字段</td>
</tr>
<tr>
<td style="text-align:left">dataId</td>
<td style="text-align:left">string</td>
<td style="text-align:left">是</td>
<td style="text-align:left">配置 ID</td>
</tr>
<tr>
<td style="text-align:left">group</td>
<td style="text-align:left">string</td>
<td style="text-align:left">是</td>
<td style="text-align:left">配置分组</td>
</tr>
</tbody>
</table>
<h3>返回参数</h3>
<table>
<thead>
<tr>
<th style="text-align:left">参数类型</th>
<th style="text-align:left">描述</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">boolean</td>
<td style="text-align:left">是否删除成功</td>
</tr>
</tbody>
</table>
<h3>错误编码</h3>
<table>
<thead>
<tr>
<th style="text-align:left">错误代码</th>
<th style="text-align:left">描述</th>
<th style="text-align:left">语义</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">400</td>
<td style="text-align:left">Bad Request</td>
<td style="text-align:left">客户端请求中的语法错误</td>
</tr>
<tr>
<td style="text-align:left">403</td>
<td style="text-align:left">Forbidden</td>
<td style="text-align:left">没有权限</td>
</tr>
<tr>
<td style="text-align:left">404</td>
<td style="text-align:left">Not Found</td>
<td style="text-align:left">无法找到资源</td>
</tr>
<tr>
<td style="text-align:left">500</td>
<td style="text-align:left">Internal Server Error</td>
<td style="text-align:left">服务器内部错误</td>
</tr>
<tr>
<td style="text-align:left">200</td>
<td style="text-align:left">OK</td>
<td style="text-align:left">正常</td>
</tr>
</tbody>
</table>
<h3>示例</h3>
<ul>
<li>请求示例</li>
</ul>
<pre><code>http:serverIp:8848/nacos/v1/cs/configs?dataId=dataIdparam&amp;group=groupParam

</code></pre>
<ul>
<li>返回示例</li>
</ul>
<pre><code>true
</code></pre>
<h1>服务发现API</h1>
<h2>注册实例</h2>
<h3>描述</h3>
<p>注册一个实例到服务。</p>
<h3>请求类型</h3>
<p>PUT</p>
<h3>请求路径</h3>
<pre><code class="language-plain">/nacos/v1/ns/instance
</code></pre>
<h3>请求参数</h3>
<table>
<thead>
<tr>
<th style="text-align:left">名称</th>
<th style="text-align:left">类型</th>
<th style="text-align:left">是否必选</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">ip</td>
<td style="text-align:left">字符串</td>
<td style="text-align:left">是</td>
<td>服务实例IP</td>
</tr>
<tr>
<td style="text-align:left">port</td>
<td style="text-align:left">int</td>
<td style="text-align:left">是</td>
<td>服务实例port</td>
</tr>
<tr>
<td style="text-align:left">tenant</td>
<td style="text-align:left">字符串</td>
<td style="text-align:left">否</td>
<td>租户ID</td>
</tr>
<tr>
<td style="text-align:left">weight</td>
<td style="text-align:left">double</td>
<td style="text-align:left">否</td>
<td>权重</td>
</tr>
<tr>
<td style="text-align:left">enable</td>
<td style="text-align:left">boolean</td>
<td style="text-align:left">否</td>
<td>是否上线</td>
</tr>
<tr>
<td style="text-align:left">healthy</td>
<td style="text-align:left">boolean</td>
<td style="text-align:left">否</td>
<td>是否健康</td>
</tr>
<tr>
<td style="text-align:left">metadata</td>
<td style="text-align:left">字符串</td>
<td style="text-align:left">否</td>
<td>扩展信息</td>
</tr>
<tr>
<td style="text-align:left">clusterName</td>
<td style="text-align:left">字符串</td>
<td style="text-align:left">否</td>
<td>集群名</td>
</tr>
<tr>
<td style="text-align:left">serviceName</td>
<td style="text-align:left">字符串</td>
<td style="text-align:left">是</td>
<td>服务名</td>
</tr>
</tbody>
</table>
<h3>示例请求</h3>
<pre><code class="language-plain">curl -X PUT 'http://127.0.0.1:8848/nacos/v1/ns/instance?port=8848&amp;healthy=true&amp;ip=11.11.11.11&amp;weight=1.0&amp;serviceName=nacos.test.3&amp;encoding=GBK&amp;tenant=n1''
</code></pre>
<h3>示例返回</h3>
<p>ok</p>
<h2>删除实例</h2>
<h3>描述</h3>
<p>删除服务下的一个实例。</p>
<h3>请求类型</h3>
<p>DELETE</p>
<h3>请求路径</h3>
<pre><code class="language-plain">/nacos/v1/ns/instance
</code></pre>
<h3>请求参数</h3>
<table>
<thead>
<tr>
<th style="text-align:left">名称</th>
<th style="text-align:left">类型</th>
<th style="text-align:left">是否必选</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">serviceName</td>
<td style="text-align:left">字符串</td>
<td style="text-align:left">是</td>
<td>服务名</td>
</tr>
<tr>
<td style="text-align:left">ip</td>
<td style="text-align:left">字符串</td>
<td style="text-align:left">是</td>
<td>服务实例IP</td>
</tr>
<tr>
<td style="text-align:left">port</td>
<td style="text-align:left">int</td>
<td style="text-align:left">是</td>
<td>服务实例port</td>
</tr>
<tr>
<td style="text-align:left">cluster</td>
<td style="text-align:left">字符串</td>
<td style="text-align:left">是</td>
<td>集群名称</td>
</tr>
<tr>
<td style="text-align:left">tenant</td>
<td style="text-align:left">字符串</td>
<td style="text-align:left">否</td>
<td>租户ID</td>
</tr>
</tbody>
</table>
<h3>示例请求</h3>
<pre><code class="language-plain">curl -X DELETE 127.0.0.1:8848/nacos/v1/ns/instance?serviceName=nacos.test.1&amp;ip=1.1.1.1&amp;port=8888&amp;cluster=TEST1
</code></pre>
<h3>示例返回</h3>
<p>ok</p>
<h2>修改实例</h2>
<h3>描述</h3>
<p>修改服务下的一个实例。</p>
<h3>请求类型</h3>
<p>POST</p>
<h3>请求路径</h3>
<pre><code class="language-plain">/nacos/v1/ns/instance/update
</code></pre>
<h3>请求参数</h3>
<table>
<thead>
<tr>
<th style="text-align:left">名称</th>
<th style="text-align:left">类型</th>
<th style="text-align:left">是否必选</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">serviceName</td>
<td style="text-align:left">字符串</td>
<td style="text-align:left">是</td>
<td>服务名</td>
</tr>
<tr>
<td style="text-align:left">ip</td>
<td style="text-align:left">字符串</td>
<td style="text-align:left">是</td>
<td>服务实例IP</td>
</tr>
<tr>
<td style="text-align:left">port</td>
<td style="text-align:left">int</td>
<td style="text-align:left">是</td>
<td>服务实例port</td>
</tr>
<tr>
<td style="text-align:left">cluster</td>
<td style="text-align:left">字符串</td>
<td style="text-align:left">是</td>
<td>集群名称</td>
</tr>
<tr>
<td style="text-align:left">tenant</td>
<td style="text-align:left">字符串</td>
<td style="text-align:left">否</td>
<td>租户ID</td>
</tr>
<tr>
<td style="text-align:left">weight</td>
<td style="text-align:left">double</td>
<td style="text-align:left">否</td>
<td>权重</td>
</tr>
<tr>
<td style="text-align:left">metadata</td>
<td style="text-align:left">JSON</td>
<td style="text-align:left">否</td>
<td>扩展信息</td>
</tr>
</tbody>
</table>
<h3>示例请求</h3>
<pre><code class="language-plain">curl -X POST 127.0.0.1:8848/nacos/v1/ns/instance/update?serviceName=nacos.test.1&amp;ip=1.1.1.1&amp;port=8888&amp;cluster=TEST1&amp;weight=8&amp;metadata={}
</code></pre>
<h3>示例返回</h3>
<p>ok</p>
<h2>查询实例列表</h2>
<h3>描述</h3>
<p>查询服务下的实例列表</p>
<h3>请求类型</h3>
<p>GET</p>
<h3>请求路径</h3>
<pre><code class="language-plain">/nacos/v1/ns/instance/list
</code></pre>
<h3>请求参数</h3>
<table>
<thead>
<tr>
<th style="text-align:left">名称</th>
<th style="text-align:left">类型</th>
<th style="text-align:left">是否必选</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">serviceName</td>
<td style="text-align:left">字符串</td>
<td style="text-align:left">是</td>
<td>服务名</td>
</tr>
<tr>
<td style="text-align:left">tenant</td>
<td style="text-align:left">字符串</td>
<td style="text-align:left">否</td>
<td>租户ID</td>
</tr>
<tr>
<td style="text-align:left">clusters</td>
<td style="text-align:left">字符串，多个集群用逗号分隔</td>
<td style="text-align:left">否</td>
<td>集群名称</td>
</tr>
<tr>
<td style="text-align:left">healthyOnly</td>
<td style="text-align:left">boolean</td>
<td style="text-align:left">否，默认为false</td>
<td>是否只返回健康实例</td>
</tr>
</tbody>
</table>
<h3>示例请求</h3>
<pre><code class="language-plain">curl -X GET 127.0.0.1:8848/nacos/v1/ns/instance/list?serviceName=nacos.test.1
</code></pre>
<h3>示例返回</h3>
<pre><code class="language-json">{
	<span class="hljs-attr">"dom"</span>: <span class="hljs-string">"nacos.test.1"</span>,
	<span class="hljs-attr">"cacheMillis"</span>: <span class="hljs-number">1000</span>,
	<span class="hljs-attr">"useSpecifiedURL"</span>: <span class="hljs-literal">false</span>,
	<span class="hljs-attr">"hosts"</span>: [{
		<span class="hljs-attr">"valid"</span>: <span class="hljs-literal">true</span>,
		<span class="hljs-attr">"marked"</span>: <span class="hljs-literal">false</span>,
		<span class="hljs-attr">"instanceId"</span>: <span class="hljs-string">"10.10.10.10-8888-DEFAULT-nacos.test.1"</span>,
		<span class="hljs-attr">"port"</span>: <span class="hljs-number">8888</span>,
		<span class="hljs-attr">"ip"</span>: <span class="hljs-string">"10.10.10.10"</span>,
		<span class="hljs-attr">"weight"</span>: <span class="hljs-number">1.0</span>,
		<span class="hljs-attr">"metadata"</span>: {}
	}],
	<span class="hljs-attr">"checksum"</span>: <span class="hljs-string">"3bbcf6dd1175203a8afdade0e77a27cd1528787794594"</span>,
	<span class="hljs-attr">"lastRefTime"</span>: <span class="hljs-number">1528787794594</span>,
	<span class="hljs-attr">"env"</span>: <span class="hljs-string">""</span>,
	<span class="hljs-attr">"clusters"</span>: <span class="hljs-string">""</span>
}
</code></pre>
<h2>查询实例详情</h2>
<h3>描述</h3>
<p>查询一个服务下个某个实例详情。</p>
<h3>请求类型</h3>
<p>GET</p>
<h3>请求路径</h3>
<pre><code class="language-plain">/nacos/v1/ns/instance
</code></pre>
<h3>请求参数</h3>
<table>
<thead>
<tr>
<th style="text-align:left">名称</th>
<th style="text-align:left">类型</th>
<th style="text-align:left">是否必选</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">serviceName</td>
<td style="text-align:left">字符串</td>
<td style="text-align:left">是</td>
<td>服务名</td>
</tr>
<tr>
<td style="text-align:left">ip</td>
<td style="text-align:left">字符串</td>
<td style="text-align:left">是</td>
<td>实例IP</td>
</tr>
<tr>
<td style="text-align:left">port</td>
<td style="text-align:left">字符串</td>
<td style="text-align:left">是</td>
<td>实例端口</td>
</tr>
<tr>
<td style="text-align:left">tenant</td>
<td style="text-align:left">字符串</td>
<td style="text-align:left">否</td>
<td>租户ID</td>
</tr>
<tr>
<td style="text-align:left">clusters</td>
<td style="text-align:left">字符串，多个集群用逗号分隔</td>
<td style="text-align:left">否</td>
<td>集群名称</td>
</tr>
<tr>
<td style="text-align:left">healthyOnly</td>
<td style="text-align:left">boolean</td>
<td style="text-align:left">否，默认为false</td>
<td>是否只返回健康实例</td>
</tr>
</tbody>
</table>
<h3>示例请求</h3>
<pre><code class="language-plain">curl -X GET '127.0.0.1:8848/nacos/v1/ns/instance?serviceName=nacos.test.2&amp;ip=10.10.10.10&amp;port=8888&amp;cluster=DEFAULT'
</code></pre>
<h3>示例返回</h3>
<pre><code class="language-json">{
	<span class="hljs-attr">"metadata"</span>: {},
	<span class="hljs-attr">"instanceId"</span>: <span class="hljs-string">"10.10.10.10-8888-DEFAULT-nacos.test.2"</span>,
	<span class="hljs-attr">"port"</span>: <span class="hljs-number">8888</span>,
	<span class="hljs-attr">"service"</span>: <span class="hljs-string">"nacos.test.2"</span>,
	<span class="hljs-attr">"healthy"</span>: <span class="hljs-literal">false</span>,
	<span class="hljs-attr">"ip"</span>: <span class="hljs-string">"10.10.10.10"</span>,
	<span class="hljs-attr">"clusterName"</span>: <span class="hljs-string">"DEFAULT"</span>,
	<span class="hljs-attr">"weight"</span>: <span class="hljs-number">1.0</span>
}
</code></pre>
</div></div></section><footer class="footer-container" data-reactid="121"><div class="footer-body" data-reactid="122"><img src="/img/nacos_gray.png" data-reactid="123"/><div class="cols-container" data-reactid="124"><div class="col col-12" data-reactid="125"><h3 data-reactid="126">愿景</h3><p data-reactid="127">Nacos 通过提供简单易用的动态服务发现、服务配置、服务共享与管理等服务基础设施，帮助用户在云原生时代，在私有云、混合云或者公有云等所有云环境中，更好的构建、交付、管理自己的微服务平台，更快的复用和组合业务服务，更快的交付商业创新的价值，从而为用户赢得市场。</p></div><div class="col col-6" data-reactid="128"><dl data-reactid="129"><dt data-reactid="130">文档</dt><dd data-reactid="131"><a href="/zh-cn/docs/what-is-nacos.html" target="_self" data-reactid="132">概览</a></dd><dd data-reactid="133"><a href="/zh-cn/docs/quick-start.html" target="_self" data-reactid="134">快速开始</a></dd><dd data-reactid="135"><a href="/zh-cn/docs/contributing.html" target="_self" data-reactid="136">开发者指南</a></dd></dl></div><div class="col col-6" data-reactid="137"><dl data-reactid="138"><dt data-reactid="139">资源</dt><dd data-reactid="140"><a href="/zh-cn/community/index.html" target="_self" data-reactid="141">社区</a></dd></dl></div></div><div class="copyright" data-reactid="142"><span data-reactid="143">@ 2018 The Nacos Authors | An Alibaba Middleware (Aliware) Project</span></div></div></footer></div></div>
	<script src="https://f.alicdn.com/react/15.4.1/react-with-addons.min.js"></script>
	<script src="https://f.alicdn.com/react/15.4.1/react-dom.min.js"></script>
	<script>
		window.rootPath = '';
  </script>
	<script src="/build/documentation.js"></script>
</body>
</html>